package o;

import android.app.Activity;
import android.app.Fragment;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build.VERSION;
import android.os.Looper;
import android.util.Log;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.Arrays;
import java.util.Map.Entry;
import o.fig.e;

public class fgf extends fjb {
    private PendingIntent ˋ;
    private final fft ॱ;

    public fgf(fhz o_fhz, fhw o_fhw, ffb o_ffb, String str) {
        super(o_fhz, o_fhw);
        this.ॱ = (fft) fga.ˊ(o_ffb, new Class[]{fft.class}, "com.huawei.hmf.orb.aidl.IRemoteActivity", str);
    }

    public fgf(fhz o_fhz, fjb o_fjb, PendingIntent pendingIntent) {
        super(o_fhz, o_fjb);
        this.ॱ = null;
        this.ˋ = pendingIntent;
    }

    protected void ˊ(Context context, Intent intent) {
        PendingIntent ˏ = ˏ(hashCode());
        if (ˏ != null) {
            Intent ॱ = ॱ(context);
            if (intent != null) {
                ॱ.fillIn(intent, 0);
            }
            try {
                context.startIntentSender(ˏ.getIntentSender(), ॱ, 0, 0, 0);
            } catch (Exception e) {
            }
        }
    }

    protected void ˊ(Context context, Intent intent, int i) {
        PendingIntent ˏ = ˏ(i);
        if (ˏ != null) {
            Intent ॱ = ॱ(context);
            if (intent != null) {
                ॱ.fillIn(intent, 0);
            }
            try {
                Fragment ॱ2 = fiy.ॱ((Activity) context, i);
                if (ॱ2 != null) {
                    if (VERSION.SDK_INT >= 24) {
                        ॱ2.startIntentSenderForResult(ˏ.getIntentSender(), i, ॱ, 0, 0, 0, null);
                        return;
                    }
                    String str = (String) fhp.ˊ(ॱ2, Fragment.class, "mWho");
                    if (Looper.myLooper() == null) {
                        Looper.prepare();
                    }
                    Activity activity = new Activity();
                    fhp.ˋ(activity, Activity.class, "mEmbeddedID", str);
                    ((Activity) context).startIntentSenderFromChild(activity, ˏ.getIntentSender(), i, ॱ, 0, 0, 0);
                }
            } catch (Exception e) {
                Log.e("RemoteUIModule", "start remote's activity failed, " + e.getMessage());
            }
        }
    }

    PendingIntent ˏ(int i) {
        if (this.ˋ != null) {
            return this.ˋ;
        }
        return this.ॱ.ˎ(i);
    }

    protected void ˊ(fid o_fid) {
        Class cls;
        fik o_fik = (fik) fih.ˋ(this);
        if (!o_fik.ˊ()) {
            for (Entry entry : o_fik.ˏ().entrySet()) {
                String str = (String) entry.getKey();
                cls = (Class) entry.getValue();
                if (Activity.class.isAssignableFrom(cls)) {
                    o_fid.add(str, new fig(e.EXPLICIT_INJECT, ˊ(cls, ˋ(str), (int) HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR)));
                } else {
                    throw new IllegalArgumentException("Can not inject non Activity `" + cls + "` to remote.");
                }
            }
        }
        if (ˎ()) {
            cls = ˋ().ˋ();
            if (cls != null) {
                for (String str2 : fih.ˏ(cls)) {
                    fjb ˎ = fho.ˏ().ˋ(o_fid.getModuleName()).ˎ(str2);
                    o_fid.add(str2, new fig(e.IMPLICIT_INJECT, ˊ(ˎ.ˋ().ˎ(), ˎ.hashCode(), (int) HwAccountConstants.FLAG_TRANS_NAVIGATION_BAR)));
                }
            }
        }
    }

    private PendingIntent ˊ(Class cls, int i, int i2) {
        Context ˎ = fis.ˎ();
        return PendingIntent.getActivity(ˎ, i, new Intent(ˎ, cls), i2);
    }

    public int ˋ(Object obj) {
        return Arrays.hashCode(new Object[]{this, obj});
    }
}
